<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../../vue.js"></script>
    <style>
        .box1 {
            width: 100px;
            height: 100px;
            background-color: aqua;
            display: block;
        }
        
        .box2 {
            width: 100px;
            height: 100px;
            background-color: rgb(25, 221, 64);
            /* display: none; */
        }
        
        .show {
            display: block;
        }
        
        .hide {
            display: none;
        }
    </style>
</head>

<body>
    <div id="app">
        <button @click="btn">按钮</button>
        <div :class="box?'box1':'box2'"></div>
        <hr />
        <div :class="a==1?'show':'hide'" :style="box11">1</div>
        <div :class="a==2?'show':'hide'" :style="box22">2</div>
        <button @click="b(1)">按钮1</button>
        <button @click="b(2)">按钮2</button>
    </div>

    <script>
        new Vue({
            el: "#app",
            data: {
                box: true,
                box11: {
                    width: "100px",
                    height: "100px",
                    backgroundColor: "aqua",
                },
                box22: {
                    width: "100px",
                    height: "100px",
                    backgroundColor: "pink",
                },
                a: true,
            },
            methods: {
                btn() {
                    this.box = !this.box;
                },
                b(a) {
                    // console.log(a);
                    this.a = a;
                },
            },
        });
    </script>
</body>

</html>